/*This file is part of AENIMA. AENIMA is a module of BCI++ framework for the implementation of brain computerinterface systems. 
AEnima is intended for use with BCI++ only.

BCI++ is a project of the Sensibilab of the Politecnico di Milano. 

AENIMA is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as 
published by the Free Software Foundation, either version 3 of 
the License, or (at your option) any later version.

AENIMA is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU General Public License
and the GNU Lesser General Public License along with AENIMA.  
If not, see <http://www.gnu.org/licenses/>.*/

/*!
	\file	L4686SDK.h
	 \b L4686SDK library for BTicino L4686SDK and Openwebnet protocol

	\author	Paolo Perego E-Mail: info.sensibilab@polimi.it

	\date	2007-09-06 creation \n
		2008-01-27 last modification

	\b COPYRIGHT: 
		This program is property of Sensibilab - Campus Ponit - Lecco
*/

#include "myserial.h"
#include "myhomedef.h"


/*!\fn int controllo_ACK(void)
Function for the ACK and NACK control. After a generic operation, the L4686SDK device get
back an ACK or NACK: this function return 0 in an ACK is present and 1 if there is NACK.
If the function doesn't get back any reply for more than 5 seconds, it returns  the value -1.*/ 
int controllo_ACK(void);
/*!\fn int on_luce (int indirizzo)
Function for the starting of light point.\n
The light can be commanded both point to point and as environment according to the used address.\n
\param indirizzo: it is address on the SCS bus, if it is a number <9 the environments are commanded, otherwise
individual lights are managed.\n
For the manage of scenarios look for the specific function.\n
For turning on all the lights you must use the address 0.*/
int on_luce (int indirizzo);
/*!\fn int off_luce (int indirizzo)
Function to turning of the lights\n
For the features of the function referring to the function on_luce*/
int off_luce (int indirizzo);
/*!\fn int tapparella (int indirizzo)
Function for the control of electric shutters.\n
Like the lights, the shutters can be commanded individually or as environment.\n
Using this function, the device is activated for 5 seconds.
\param indirizzo: this is the address on SCS bus, if it is <9 the environments are driven
otherwise the single shutters.\n
For the drive of scenarios and group look for the specific functions.*/
int tapparella (int indirizzo);
/*!\fn int on_scen (int num, int indirizzo)
Function for the activation of scenario.
\param num: This is the number of the scenario. 
\param indirizzo: This is the address of BTicino scenario module.*/
int on_scen (int num, int indirizzo);
/*!\fn int on_prog_scen (int num, int indirizzo)
This function is used for setting the scenario module in setup mode to create a new scenario.
After this operation, to setup a new scenario, the user must turn on and regulate the device
that he want to put into the new scenario. When the setup is done, the user must come out 
from the setup mode using the function off_prog_scen.
In the function is included the automatic unlock of the scenario module.
\param num: This  is the number of the scenario to set up.
\param indirizzo: This is the address of the scenario module.*/
int on_prog_scen (int num, int indirizzo);
/*!\fn int off_prog_scen (int num, int indirizzo)
This function is used to exit form the setup mode of the scenario module.*/
int off_prog_scen (int num, int indirizzo);
/*!\fn int del_all_scen (int indirizzo)
This function deletes the memory of scenario module. Using this function, scenarios on the module
are deleted. 
\param indirizzo: address of the scenario module*/
int del_all_scen (int indirizzo);
/*!\fn int del_scen (int num, int indirizzo)
Function to delete one scenario.
\param num: number of the scenario to be deleted.
\param indirizzo: address of the scenario module.*/
int del_scen (int num, int indirizzo);
/*!\fn int on_gruppo (int num_gruppo)
Function to turn on a group.
\param num_gruppo: this is the identification number of the group
The number is between 0 and 9. There are max 9 groups on a single SCS bus.*/
int on_gruppo (int num_gruppo);
/*!\fn int off_gruppo (int num_gruppo)
Function to turn off a group.
\param num_gruppo: this is the identification number of the group
The number is between 0 and 9. There are max 9 groups on a single SCS bus.*/
int off_gruppo (int num_gruppo);
/*!\fn int on_luce_scala (int indirizzo)
Function to turn on the stair lights. This function turns on the lamps for 15 minutes.\n
The time can be modified changing directly the OpenWebNet command in this function.
\param indirizzo: SCS address of the light point.*/
int on_luce_scala (int indirizzo);
/*!\fn int leggi_stato (char* buf, int indirizzo)
Function to read the state of a device.
\param buf: pointer to the string of nine chars for reading the state.
\param indirizzo: SCS address of the device.*/
int leggi_stato (char* buf, int indirizzo);
/*!\fn int leggi_stato_gruppo (char* buf, int indirizzo)
Function to read a group state.
\param buf: pointer to the string of nine chars for reading the state.
\param indirizzo: SCS address of the group*/
int leggi_stato_gruppo (char* buf, int indirizzo);
/*!\fn int connessione()
Function to control the connection between the PC and BTicino L4686SDKsdk; 
if the connection is ready the function return 0, else -1.*/
int connessione();

